#include <iostream>
#include <fstream>
#include <limits>

void check(int64_t a, int64_t b) {
    if(a < b) {
        std::cerr << "error" << a << "   " << b << std::endl;
        exit(-1);
    }
}

int main() {
    std::ifstream file("result.txt", std::ios::binary);
    if(!file) {
        std::cerr << "file cannot open" << std::endl;
    }
    std::size_t bytesRead = 0;

    constexpr std::size_t bufferSize = 4096;
    constexpr std::size_t maxNumbersPerBuffer = bufferSize / sizeof(int64_t);
    int64_t buffer[bufferSize];
    auto last = std::numeric_limits<int64_t>::min();

    while (true) {
        file.read(reinterpret_cast<char*>(buffer), bufferSize);
        std::size_t bytesReadInBuffer = file.gcount();
        std::size_t numbersRead = bytesReadInBuffer / sizeof(int64_t);

        if (numbersRead == 0) {
            break;
        }

        for (std::size_t i = 0; i < numbersRead; ++i) {
            // check
            if(i == 0) {
                check(buffer[0], last);
            } else {
                check(buffer[i], buffer[i - 1]);
            }
        }
        last = buffer[numbersRead - 1];

        bytesRead += bytesReadInBuffer;
    }

    file.close();
    std::cout << "check pass==========" << std::endl;
}